package com.lq.ecoldchain.ui.withdraw.history

import android.arch.lifecycle.MutableLiveData
import com.lq.ecoldchain.base.viewmodel.BaseViewModel
import com.lq.ecoldchain.entity.WithDraw
import com.lq.ecoldchain.entity.WithDrawBean
import com.lq.ecoldchain.internet.BaseObserver

/*
*2019/1/6 0006  15:42
*function by lq
*/
class WithdrawHistoryViewModel:BaseViewModel(){
    val refreshing by lazy { MutableLiveData<Boolean>() }
    val list by lazy { ArrayList<WithDraw>() }
    val adapter by lazy{ WithdrawHistoryAdapter(list)}
    var page =1
    var limit = 10
    init {
        obtainWithdraw()
    }

    fun refreshData(){
        refreshing.value = true
        obtainWithdraw()
    }

   private fun obtainWithdraw(){
       BaseNetCore.ApiServiceImpl.obtainWithdrawHistory("$page","$limit").compose(RxTransformer.switchSchedulers()).subscribe(object:BaseObserver<WithDrawBean>(){
           override fun onSuccess(t: WithDrawBean?) {
               refreshing.value = false
           }

           override fun onFail(code: String) {
               refreshing.value = false
           }
       })
    }
}